/**********************************************************************************
 * Code license:  GNU General Public License v3                                   *
 * Main page:     https://code.google.com/p/library-cross-platform/               *
 * Issue tracker: https://code.google.com/p/library-cross-platform/issues/list    *
***********************************************************************************/

package library.ui;
import java.util.*;

@SuppressWarnings({"rawtypes"})
public class RadioButtonContainer extends ElementContainer
{
  public RadioButtonContainer() {
    super(RADIOBUTTON_CONTAINER_TYPE);
  }
  
  public RadioButtonContainer(String name) {
    super(RADIOBUTTON_CONTAINER_TYPE);
    setName(name);    
  }
  
  public void resetState() {
    Iterator           it      = container.iterator();
    RadioButtonElement element = null;
    while(it.hasNext()) {
      element = (RadioButtonElement)it.next();
      element.setState(false);
    }    
  }
  
  public void setActive(int index) {
   resetState();
   ((RadioButtonElement)container.get(index)).setState(true);
  }

  public void setActive(RadioButtonElement element) {
   resetState();
   RadioButtonElement elmnt = (RadioButtonElement)getByID(element.getElementID());
   elmnt.setState(true);
  }
}